package com.yunqiao.api.controller;
import com.yunqiao.common.config.SysConfig;
import com.yunqiao.common.utils.ApiResponse;
import com.yunqiao.service.api.HostService;
import com.yunqiao.service.api.entity.HostEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 
 *
 * @author zhuwei
 * @email 121203654@qq.com
 * @date 2019-09-05 15:58:15
 */
@RestController
@RequestMapping("/api/today/host")
public class HostController {
    @Autowired
    private HostService hostService;

    /**
     * 列表
     */
    @RequestMapping("/list/{version}")
    public ApiResponse list(@PathVariable String version){
        List<HostEntity> list=hostService.queryList(version);
        for (int i = 0; i < list.size(); i++) {
            HostEntity hostEntity =  list.get(i);
            if(hostEntity.getBool()){
                return new ApiResponse(hostEntity.getHost());
            }
        }
        return new ApiResponse(SysConfig.host.replace("http","https")+"/yunqiao");
    }


}
